{include file="common:header" /}
{include file="common:side" /}
    <div id="page-wrapper">
      <!-- 舆情日报 -->
      <!--*************************** content部分开始 ******************-->
      <div class="container-fluid" id="m_main">
        <div class="row m-t-20">
          <div class="col-sm-12">
            <div class="white-box">
              <h2 class="box-title m-b-20">编辑教室信息</h2>
              <div class="row">
                <div class="col-sm-4">
                  <div class="form-group">
                    <label class="control-label">学员姓名：</label>
                    <input type="text" class="form-control" placeholder="" v-model="students.name">
                  </div>
                </div>
              </div>
              <div class="row">
                <div class="col-sm-4">
                  <div class="form-group">
                    <label class="control-label">年龄（岁）：</label>
                    <input type="text" class="form-control" placeholder="" v-model="students.age">
                  </div>
                </div>
              </div>
              <div class="row">
                <div class="col-sm-4">
                  <div class="form-group">
                    <label class="control-label">爸爸姓名：</label>
                    <input type="text" class="form-control" placeholder="" v-model="students.father_name">
                  </div>
                </div>
              </div>
              <div class="row">
                <div class="col-sm-4">
                  <div class="form-group">
                    <label class="control-label">妈妈姓名：</label>
                    <input type="text" class="form-control" placeholder="" v-model="students.mother_name">
                  </div>
                </div>
              </div>
              <div class="row">
                <div class="col-sm-4">
                  <div class="form-group">
                    <label class="control-label">联系电话：</label>
                    <input type="text" class="form-control" placeholder="" v-model="students.phone">
                  </div>
                </div>
              </div>
              <div class="row">
                <div class="col-sm-4">
                  <div class="form-group">
                    <label class="control-label">状态：</label>
                    <select id="study_status" class="selectpicker" data-style="form-control" @change="">
                      <option value="">请选择</option>
                      {foreach $study_statusarr as $key=>$vo } 
                      <option {if $key==$info.study_status}selected{/if} value="{$key}">{$vo}</option>
                      {/foreach}
                    </select>
                  </div>
                </div>
              </div>
              <div class="row">
                <div class="col-sm-4">
                  <div class="form-group">
                    <label class="control-label">财务信息备注：</label>
                    <input type="text" class="form-control" placeholder="" v-model="students.remark">
                  </div>
                </div>
              </div>
              <div class="row m-t-40">
                <div class="col-sm-8 ta-c">
                  <button type="button" name="" class="btn btn-outline btn-primary m-r-40" @click="doSubmit()">提交</button>
                </div>
              </div>
            </div>
          </div>
        </div>

        <!-- /.row -->
      </div>
      <!--*************************** content部分结束 ******************-->

      <!-- <footer class="footer text-center"> 2017 &copy; Ample Admin brought to you by themedesigner.in </footer> -->
    </div>
  {include file="common:js" /}
  {include file="common:footer" /}
  <script src="/web/js/edit.js"></script>

  <script type="text/javascript">
    var vm = new Vue({
      el: '#m_main',
      data() {
        return {
          sid: '{$sid}',
          cid: '{$cid}',
          students: {}
        }
      },
      mounted() {
        this.requestData();
      },
      methods: {
        requestData() {
          let that = this;
          axios.post('/dboard/students/infoData', {cid: that.cid},{headers: {'X-Requested-with':'XMLHttpRequest'}}).then(res => {
            // console.log(res);
            if(res.data.Code == 0){
              that.students = res.data.Data.students;
            }else{
              alert(res.data.Msg)
            }
          }).catch(err => {
            console.log(err);
          })
        },
        // 提交
        doSubmit(){
          var that = this;
          var study_status = $('#study_status').find('option:selected').val();
          var param = {
            sid: that.sid,
            cid: that.cid,
            name: that.students.name,
            age: that.students.age,
            mother_name: that.students.mother_name,
            father_name: that.students.father_name,
            study_status: study_status,
            phone: that.students.phone,
            remark: that.students.remark,
          }
          axios.post('/dboard/students/editStudentsinfo', param,{headers: {'X-Requested-with':'XMLHttpRequest'}}).then(res => {
            // console.log(res);
            if(res.data.Code == 0){
              //请求成功
              alert(res.data.Msg);
              window.location.href = '/dboard/students/lists';
            }else{
              alert(res.data.Msg)
            }
          }).catch(err => {
            console.log(err);
          })
        },
      }
    })
  </script>
